//package vn.com.vega.music.syncmanager;
//
//import java.util.Calendar;
//import java.util.TimeZone;
//
//import vn.com.vega.chacha.v2.receiver.SyncDataReceiver;
//
//import android.app.AlarmManager;
//import android.app.PendingIntent;
//import android.content.Context;
//import android.content.Intent;
//
//public class SyncUtil {
//	private static final int TIME_INTERVAL = 300000; // 5 minutes
//	
//	public static void startSync(Context ctx) {
//		// Before schedule we start sync first time
//		ctx.startService(new Intent(ctx, SyncDataService.class));
//		
//		// Schedule run sync after 5 minutes interval
//		Calendar updateTime = Calendar.getInstance();
//		updateTime.add(Calendar.MINUTE, 5);
//	 
//	    Intent syncData = new Intent(ctx, SyncDataReceiver.class);
//	    PendingIntent recurringSync = PendingIntent.getBroadcast(ctx,
//	            0, syncData, PendingIntent.FLAG_CANCEL_CURRENT);
//	    AlarmManager alarms = (AlarmManager) ctx.getSystemService(
//	            Context.ALARM_SERVICE);
//	    alarms.setInexactRepeating(AlarmManager.RTC,
//	    		Calendar.getInstance().getTimeInMillis(),
//	            TIME_INTERVAL, recurringSync);
////	    alarms.set(AlarmManager.RTC, updateTime.getTimeInMillis(), recurringSync);
//	}
//	
//	public static void stopSync(Context ctx) {
//		Intent syncData = new Intent(ctx, SyncDataService.class);
//		PendingIntent recurringSync = PendingIntent.getBroadcast(ctx,
//	            0, syncData, PendingIntent.FLAG_CANCEL_CURRENT);
//	    AlarmManager alarms = (AlarmManager) ctx.getSystemService(
//	            Context.ALARM_SERVICE);
//	    alarms.cancel(recurringSync);
//	}
//
//}
